package nz.co.doherty.gwtpbreadcrumbs.client.gin;

import nz.co.doherty.gwtpbreadcrumbs.client.ClientPlaceManager;
import nz.co.doherty.gwtpbreadcrumbs.client.FailureHandlerAlert;
import nz.co.doherty.gwtpbreadcrumbs.client.i8n.ClientConstants;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.app.AppPresenter;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.app.AppView;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.app.AppViewImpl;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.app.AppPresenter.AppProxy;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.customers.CustomerCreatePresenter;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.customers.CustomerCreateView;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.customers.CustomerCreateViewImpl;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.customers.CustomerInfoPresenter;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.customers.CustomerInfoView;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.customers.CustomerInfoViewImpl;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.customers.CustomerListItemPresenter;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.customers.CustomerListItemView;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.customers.CustomerListItemViewImpl;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.customers.CustomerListPresenter;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.customers.CustomerListView;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.customers.CustomerListViewImpl;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.customers.CustomerCreatePresenter.CustomerCreateProxy;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.customers.CustomerInfoPresenter.CustomerInfoProxy;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.customers.CustomerListPresenter.CustomerListProxy;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.home.HomePresenter;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.home.HomeView;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.home.HomeViewImpl;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.home.HomePresenter.HomeProxy;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.products.ProductCreatePresenter;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.products.ProductCreateView;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.products.ProductCreateViewImpl;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.products.ProductInfoPresenter;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.products.ProductInfoView;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.products.ProductInfoViewImpl;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.products.ProductListItemPresenter;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.products.ProductListItemView;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.products.ProductListItemViewImpl;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.products.ProductListPresenter;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.products.ProductListView;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.products.ProductListViewImpl;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.products.ProductCreatePresenter.ProductCreateProxy;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.products.ProductInfoPresenter.ProductInfoProxy;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.products.ProductListPresenter.ProductListProxy;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.topbar.TopBarPresenter;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.topbar.TopBarView;
import nz.co.doherty.gwtpbreadcrumbs.client.ui.topbar.TopBarViewImpl;

import com.google.inject.Singleton;
import com.philbeaudoin.gwtp.mvp.client.DefaultEventBus;
import com.philbeaudoin.gwtp.mvp.client.EventBus;
import com.philbeaudoin.gwtp.mvp.client.RootPresenter;
import com.philbeaudoin.gwtp.mvp.client.gin.AbstractPresenterModule;
import com.philbeaudoin.gwtp.mvp.client.proxy.ParameterTokenFormatter;
import com.philbeaudoin.gwtp.mvp.client.proxy.PlaceManager;
import com.philbeaudoin.gwtp.mvp.client.proxy.ProxyFailureHandler;
import com.philbeaudoin.gwtp.mvp.client.proxy.TokenFormatter;

public class ClientPresenterModule extends AbstractPresenterModule {

	@Override
	protected void configure() {

		// Singletons
		bind(ClientConstants.class).in(Singleton.class);
		bind(EventBus.class).to(DefaultEventBus.class).in(Singleton.class);
		bind(PlaceManager.class).to(ClientPlaceManager.class)
				.asEagerSingleton();
		bind(TokenFormatter.class).to(ParameterTokenFormatter.class);
		bind(RootPresenter.class).asEagerSingleton();
		bind(ProxyFailureHandler.class).to(FailureHandlerAlert.class).in(
			Singleton.class);

		// Non-singletons
		/* bind(ChangeMonitor.class).to(DefaultChangeMonitor.class); */

		// Presenter widget
		// FIXME: MVP - should use factory here
		bindPresenterWidget(TopBarPresenter.class, TopBarView.class,
			TopBarViewImpl.class);
		bindPresenterWidget(ProductListItemPresenter.class,
			ProductListItemView.class, ProductListItemViewImpl.class);
		bindPresenterWidget(CustomerListItemPresenter.class,
			CustomerListItemView.class, CustomerListItemViewImpl.class);

		// Presenter bundles

		// Presenters
		bindPresenter(HomePresenter.class, HomeView.class, HomeViewImpl.class,
			HomeProxy.class);
		bind(HomeView.Presenter.class).to(HomePresenter.class);
		bindPresenter(AppPresenter.class, AppView.class, AppViewImpl.class,
			AppProxy.class);

		bindPresenter(ProductListPresenter.class, ProductListView.class,
			ProductListViewImpl.class, ProductListProxy.class);
		bind(ProductListView.Presenter.class).to(ProductListPresenter.class);
		bindPresenter(ProductInfoPresenter.class, ProductInfoView.class,
			ProductInfoViewImpl.class, ProductInfoProxy.class);
		bindPresenter(ProductCreatePresenter.class, ProductCreateView.class,
			ProductCreateViewImpl.class, ProductCreateProxy.class);
		bind(ProductCreateView.Presenter.class).to(ProductCreatePresenter.class);

		bindPresenter(CustomerListPresenter.class, CustomerListView.class,
			CustomerListViewImpl.class, CustomerListProxy.class);
		bind(CustomerListView.Presenter.class).to(CustomerListPresenter.class);
		bindPresenter(CustomerInfoPresenter.class, CustomerInfoView.class,
			CustomerInfoViewImpl.class, CustomerInfoProxy.class);
		bind(CustomerInfoView.Presenter.class).to(CustomerInfoPresenter.class);
		bindPresenter(CustomerCreatePresenter.class, CustomerCreateView.class,
			CustomerCreateViewImpl.class, CustomerCreateProxy.class);
		bind(CustomerCreateView.Presenter.class).to(CustomerCreatePresenter.class);

	}
}
